package com.roadmap.ajax.handler;

import java.util.HashMap;
import java.util.Map;

import com.roadmap.entities.Category;
import com.roadmap.entities.Comment;
import com.roadmap.entities.Message;
import com.roadmap.entities.Request;
import com.roadmap.entities.ext.FriendExt;

/* generate a handler instance according to the specific type*/
@Deprecated
public class LogicHandlerFactory {
	// the mapping between the entry and its handler
	private static final Map<String, String> _handlerMap = new HashMap<String, String>();
	static {
		_handlerMap.put(Request.class.getSimpleName(), RequestHandler.class
				.getCanonicalName());
		_handlerMap.put(FriendExt.class.getSimpleName(), FriendHandler.class
				.getCanonicalName());
		_handlerMap.put(Category.class.getSimpleName(), CategoryHandler.class
				.getCanonicalName());
		_handlerMap.put(Message.class.getSimpleName(), MessageHandler.class
				.getCanonicalName());
		_handlerMap.put(Comment.class.getSimpleName(), CommentHandler.class
				.getCanonicalName());
	}

	/**
	 * if the type is invalid or not mapped to a specified handler class, return
	 * a handler proxy which provides common methods
	 */
	public static ILogicHandler getInstance(String type)
			throws InstantiationException, IllegalAccessException,
			ClassNotFoundException {
		return new LogicHandler(type);
	}
}
